/**
 * Copyright 2010 Pavel Daniel Alexandru PFA
 * 
 * Licensed under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation. You may obtain a copy of the
 * License at: http://www.gnu.org/copyleft/lesser.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.kobol.webclient.client.gin;

import com.google.inject.Singleton;
import com.gwtplatform.mvp.client.DefaultEventBus;
import com.gwtplatform.mvp.client.DefaultProxyFailureHandler;
import com.gwtplatform.mvp.client.EventBus;
import com.gwtplatform.mvp.client.RootPresenter;
import com.gwtplatform.mvp.client.gin.AbstractPresenterModule;
import com.gwtplatform.mvp.client.proxy.ParameterTokenFormatter;
import com.gwtplatform.mvp.client.proxy.PlaceManager;
import com.gwtplatform.mvp.client.proxy.ProxyFailureHandler;
import com.gwtplatform.mvp.client.proxy.TokenFormatter;
import com.kobol.webclient.client.NameTokens;
import com.kobol.webclient.client.WebclientPlaceManager;
import com.kobol.webclient.client.main.presenter.MainPagePresenter;
import com.kobol.webclient.client.main.presenter.MainPageSmartGwtPresenter;
import com.kobol.webclient.client.main.view.MainPageSmartGwtView;
import com.kobol.webclient.client.main.view.MainPageView;
import com.kobol.webclient.client.resourcecenter.presenter.HighlightsPresenter;
import com.kobol.webclient.client.resourcecenter.view.HighlightsView;
import com.kobol.webclient.client.sales.presenter.AccountsPresenter;
import com.kobol.webclient.client.sales.presenter.ActivitiesPresenter;
import com.kobol.webclient.client.sales.presenter.CalendarPresenter;
import com.kobol.webclient.client.sales.view.AccountsView;
import com.kobol.webclient.client.sales.view.ActivitiesView;
import com.kobol.webclient.client.sales.view.CalendarView;
import com.kobol.webclient.client.settings.presenter.AdministrationPresenter;
import com.kobol.webclient.client.settings.view.AdministrationView;
import com.kobol.webclient.client.signin.presenter.ErrorDialogPresenterWidget;
import com.kobol.webclient.client.signin.presenter.ErrorPagePresenter;
import com.kobol.webclient.client.signin.presenter.SignInPagePresenter;
import com.kobol.webclient.client.signin.view.ErrorDialogPopupView;
import com.kobol.webclient.client.signin.view.ErrorPageView;
import com.kobol.webclient.client.signin.view.SignInPageView;
/**
 * @author Pavel Alexandru
 *
 */
public class ClientModule extends AbstractPresenterModule {

    @Override
    protected void configure() {
	bind(EventBus.class).to(DefaultEventBus.class).in(Singleton.class);
	bind(PlaceManager.class).to(WebclientPlaceManager.class).in(Singleton.class);
	bind(TokenFormatter.class).to(ParameterTokenFormatter.class).in(Singleton.class);
	bind(RootPresenter.class).asEagerSingleton();
	bind(ProxyFailureHandler.class).to(DefaultProxyFailureHandler.class).in(Singleton.class);

	// Constants
	bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.signInPage);

	// Sign In
	bindPresenter(SignInPagePresenter.class, SignInPagePresenter.MyView.class, SignInPageView.class,
		SignInPagePresenter.MyProxy.class);

	// Main Pages
	bindPresenter(MainPagePresenter.class, MainPagePresenter.MyView.class, MainPageView.class,
		MainPagePresenter.MyProxy.class);
	bindPresenter(MainPageSmartGwtPresenter.class, MainPageSmartGwtPresenter.MyView.class,
		MainPageSmartGwtView.class, MainPageSmartGwtPresenter.MyProxy.class);
	bindSingletonPresenterWidget(ErrorDialogPresenterWidget.class, ErrorDialogPresenterWidget.MyView.class,
		ErrorDialogPopupView.class);
	
	// Error Page
	bindPresenter(ErrorPagePresenter.class, ErrorPagePresenter.MyView.class, ErrorPageView.class,
		ErrorPagePresenter.MyProxy.class);
	// Sales
	bindPresenter(ActivitiesPresenter.class, ActivitiesPresenter.MyView.class, ActivitiesView.class,
		ActivitiesPresenter.MyProxy.class);
	bindPresenter(CalendarPresenter.class, CalendarPresenter.MyView.class, CalendarView.class,
		CalendarPresenter.MyProxy.class);
	bindPresenter(AccountsPresenter.class, AccountsPresenter.MyView.class, AccountsView.class,
		AccountsPresenter.MyProxy.class);

	// Settings
	bindPresenter(AdministrationPresenter.class, AdministrationPresenter.MyView.class, AdministrationView.class,
		AdministrationPresenter.MyProxy.class);

	// Resource Centre
	bindPresenter(HighlightsPresenter.class, HighlightsPresenter.MyView.class, HighlightsView.class,
		HighlightsPresenter.MyProxy.class);
    }
}